﻿using System.Globalization;
using Def.Log;

namespace FrontDisplay
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : System.Windows.Application
    {
        static System.Threading.Mutex _instanceMutex;   // globally visible object

#if !DEBUG
        static bool IsAlreadyRunning()
        {
            const string uniqueString = "Fron Display Application";
            bool createdNew;
            _instanceMutex = new System.Threading.Mutex(false, uniqueString, out createdNew);
            return !createdNew;
        }
#endif

        public App()
        {
#if !DEBUG
            if (IsAlreadyRunning())
            {
                Shutdown();
            }
#endif

//#if DEBUG
            Logger.Listeners.Add(new FileLogListener(LogLevel.Debug, Global.ApplicationDataFolder + "Logs", FileLogListener.FileNaming.DateOnly));
            Logger.Level = LogLevel.Debug;
//#endif

            Def.Localization.CurrentCulture = new CultureInfo(Global.Config.Language);
        }
    }
}
